<%@page import="java.awt.print.Printable"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>_${customer.customerName}_发货任务列表</title>
<script language="javascript" type="text/javascript" src="${ctx}/static/datepicker/WdatePicker.js"></script>
<script type="text/javascript">
 
  //领取任务 
  function takeTask(taskId){
	  $.ajax({
			type:'post',
			url:'${ctx}/outstorageSendTask/ajaxTakeSendTask',
			data:{
				taskId:taskId
			},
			dataType:'json',
			success:function(data) {
			    if(data==true){
			      $("#queryForm").submit();
			    }else{
			      alert("网络繁忙，请稍后重试...");
			    }
			},
			error:function() {
				alert("网络繁忙，请稍后重试...");
			}
	   });
  }
  
  

</script>
</head>

<body>
<section class="content">
<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">我的发货任务</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead><tr>
			    <th>序号</th>
			    <th>商家</th>
			    <th>出库类型</th>
			    <th>作业仓库</th>
			    <th>任务编号</th>
			    <th>sku数量</th>
			    <th>商品数量</th>
			    <th>创建时间</th>
			    <th>发货执行人</th>
			    <th>任务状态</th>
			    <th>操作</th>
			</tr></thead>
		<tbody>
		<c:forEach items="${myTaskList}" var="t" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			   <td>${t.customer.customerName}</td>
			   <td>
				  <c:if test="${t.bill.billType eq 'allot' }"><font color=red>调拨出库</font></c:if> 
				  <c:if test="${t.bill.billType eq 'sale' }"><font color=blue>销售出库</font></c:if>
				  <c:if test="${t.bill.billType eq 'return' }"><font color=green>返仓出库</font></c:if>
			   </td>
			   <td>${t.warehouse.groupName}</td>
			   <td>${t.taskCode}</td>
			   <td>${t.bill.skuNum}</td>
			   <td>${t.bill.goodsNum}</td>
			   <td>${fn:substring(t.createTime,0,19)}</td>
			   <td>${t.worker.realname}</td>
			   <td>
			     <c:if test="${t.status eq 'token'}">已分配发货任务</c:if>
			     <c:if test="${t.status eq 'doing'}">发货中...</c:if>
			   </td>
			   <td>
			      <c:if test="${t.status eq 'token'}">
			         <a href="${ctx}/outstorageSendTask/v2_toSendTaskPage/${t.id}" role="button"  class="btn btn-primary" >开始任务</a>
			      </c:if>
			      <c:if test="${t.status eq 'doing'}">
			         <a href="${ctx}/outstorageSendTask/v2_toSendTaskPage/${t.id}" role="button"  class="btn btn-primary" >继续任务</a>
			      </c:if>
			   </td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</div>
	</div>
	</div>
	</div>
	
<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">未分配的发货任务</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
	<!-- 未分配的发货任务 -->
	<form class="form-search" id="queryForm" method="post" action="${ctx}/outstorageSendTask/v2_querySendTaskList" >
							<div class="form-group row">
								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 商家用户： </span>
										<select class="form-control required"  id="_customerCode" name="_customerCode"  value="${param._customerCode}" onchange="ajaxAreaGroup(this,'_warehouseCode');" >
				        <option value=""></option>
						<c:forEach items="${customerList}" var="customer">
							<option value="${customer.customerCode}"
							  <c:if test="${_customerCode eq customer.customerCode }">selected=selected</c:if>
							>${customer.customerName}</option>
						</c:forEach>
				</select> 
									</div>
								</div>
								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 作业仓库： </span> 
										 <select  name="_warehouseCode"  id="_warehouseCode" value="${param._warehouseCode}"  class="form-control">
					<option value=""></option>
					<c:forEach items="${warehouseList}" var="w" >
					   <option value="${w.groupCode}" 
					   <c:if test="${_warehouseCode eq w.groupCode }">selected=selected</c:if>
					   >${w.groupName}</option>
				   </c:forEach>
				</select>
									</div>
								</div>
								<div class="col-sm-6">
									  <button class="btn btn-primary" type="submit" style="margin-left: 10px;">搜索</button>
							</div>
						</div>
</form>

							<table class="table table-striped table-bordered table-condensed" >
		<tr>
			    <th>序号</th>
			    <th>商家</th>
			    <th>出库类型</th>
			    <th>作业仓库</th>
			    <th>任务编号</th>
			    <th>sku数量</th>
			    <th>商品数量</th>
			    <th>创建时间</th>
			    <th>发货执行人</th>
			    <th>任务状态</th>
			    <th>操作</th>
			</tr>
		<tbody>
		<c:forEach items="${untakedTaskList}" var="t" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			   <td>${t.customer.customerName}</td>
			   <td>
				  <c:if test="${t.bill.billType eq 'allot' }"><font color=red>调拨出库</font></c:if> 
				  <c:if test="${t.bill.billType eq 'sale' }"><font color=blue>销售出库</font></c:if>
				  <c:if test="${t.bill.billType eq 'return' }"><font color=green>返仓出库</font></c:if>
			   </td>
			   <td>${t.warehouse.groupName}</td>
			   <td>${t.taskCode}</td>
			   <td>${t.bill.skuNum}</td>
			   <td>${t.bill.goodsNum}</td>
			   <td>${fn:substring(t.createTime,0,19)}</td>
			   <td></td>
			   <td><font color=red>未分配发货任务</font></td>
			   <td>
			      <input type="button" class="btn btn-primary" onclick="takeTask('${t.id}');" value="领取任务"/>
			   </td>
			</tr>
		</c:forEach>
		</tbody>
		
	</table>
	
</div>
	</div>
	</div>
	</div>
	</section>
</body>
</html>
